import CryptoJS from 'crypto-js'

const KEY = CryptoJS.enc.Utf8.parse('DAIHAODAIHAO9527') 			// 秘钥

/**
 * 加密字符串
 * @param plaintext
 * @returns {*}
 * @constructor
 */
export const AES_Encrypt = (plaintext) => {
	return CryptoJS['AES'].encrypt(plaintext, KEY, {
		mode: CryptoJS['mode'].ECB,
		padding: CryptoJS['pad'].Pkcs7,
	}).toString()
}

/**
 * 解密字符串
 * @param encryptStr
 * @returns {*}
 * @constructor
 */
export const AES_Decrypt = (encryptStr) => {
	return CryptoJS['AES'].decrypt(encryptStr, KEY, {
		mode: CryptoJS['mode'].ECB,
		padding: CryptoJS['pad'].Pkcs7
	}).toString(CryptoJS['enc'].Utf8);
}





